import { withRouter } from 'next/router'
import Link from 'next/link'
import axios from 'axios'

const Lady = ({ router, list }) => {
  return (
    <>
      <div>
        {router.query.name}来为我们服务了{list}
      </div>
      <Link href="/">返回首页</Link>
    </>
  )
}

Lady.getInitialProps = async () => {
  const promise = new Promise(resolve => {
    axios.get('https://www.easy-mock.com/mock/5f8fd789bcca63581f44c444/redux/getList').then(res => {
      if (res.status === 200) {
        resolve(res.data.data.list)
      }
    })
  })
  return await promise
}

export default withRouter(Lady)
